package com.flying.invest.survey.service;

import com.flying.common.annotation.DaoCreate;
import com.flying.common.annotation.DaoQuery;
import com.flying.common.annotation.DaoRemove;
import com.flying.common.annotation.DaoUpdate;
import com.flying.common.util.Codes;
import com.flying.framework.annotation.MethodInfo;
import com.flying.framework.annotation.Param;
import com.flying.framework.annotation.Service;
import com.flying.framework.model.ActionResult;
import com.flying.framework.model.QueryResult;
import com.flying.framework.service.AbstractService;
import com.flying.invest.survey.model.Survey;
import com.flying.invest.survey.model.Survey.Status;

@Service(value="SurveyService", desc="调查问卷")
public class SurveyService extends AbstractService{
    private QuestionService qs;
    
    public void setQuestionService(QuestionService s) {
    	this.qs = s;
    }
    
	@MethodInfo("新增")
	@DaoCreate(entity=Survey.ENTITY_NAME)
	public Survey create(
			@Param(value=Survey.NAME, required=true,	desc="名称") String name,
			@Param(value=Survey.REMARKS, required=false,	desc="说明") String remarks,
			@Param(value=Survey.STATUS, required=false, enumClass=Status.class,	desc="状态") Integer status
		) {
		
		return null;
	}

	@MethodInfo("修改")
	@DaoUpdate(entity=Survey.ENTITY_NAME)
	public ActionResult update(
			@Param(value=Survey.SURVEY_ID, required=true,	desc="调查ID") Long survey_id,
			@Param(value=Survey.NAME, required=true,	desc="名称") String name,
			@Param(value=Survey.REMARKS, required=false,	desc="说明") String remarks,
			@Param(value=Survey.STATUS, required=false, enumClass=Status.class,	desc="状态") Integer status
			
		) {
		
		return null;
	}

	@MethodInfo("删除")
	@DaoRemove(entity=Survey.ENTITY_NAME)
	public ActionResult remove(
			@Param(value=Survey.SURVEY_ID, required=true,	desc="调查ID") Long survey_id
		) {
		this.qs.removeBySurveyId(survey_id);
		return null;
	}

	@MethodInfo("搜索")
	@DaoQuery(entity=Survey.ENTITY_NAME, pageable=true, modelClass=Survey.class)
	public QueryResult<Survey> findAll(
			@Param(value=Survey.STATUS, required=false, enumClass=Status.class,	desc="状态") Integer status,
			@Param(value=Codes.PAGE_NUM, 	required=false, desc="分页页号，默认0") int page,
			@Param(value=Codes.PAGE_SIZE, 	required=false, desc="分页大小，默认10") int rows) throws Exception {
		return null;
	}

	@MethodInfo("查询")
	@DaoQuery(entity=Survey.ENTITY_NAME, single=true, throwsNotFoundException=true )
	public Survey findById(
			@Param(value=Survey.SURVEY_ID, required=true,	desc="调查ID") Long survey_id
		) {
		return null;
	}

}